package com.example.mypickers;

import android.os.Bundle;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.DialogFragment;
import android.view.Menu;
import android.view.View;
import android.widget.Button;

@SuppressLint({ "NewApi", "ValidFragment" })
public class MainActivity extends Activity {
	public Button pick_btn1,pick_btn2;
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		setView();
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}
	
	private void setView(){
		pick_btn1 = (Button)findViewById(R.id.pick_btn1);
		pick_btn1.setOnClickListener(new Button.OnClickListener(){

			@Override
			public void onClick(View v) {
				showTimePickerDialog(v);
			}
			
		});
		
		pick_btn2 = (Button)findViewById(R.id.pick_btn2);
		pick_btn2.setOnClickListener(new Button.OnClickListener(){

			@Override
			public void onClick(View v) {
				showDatePickerDialog(v);
			}
			
		});
	}
	
	public void showTimePickerDialog(View v) {
		DialogFragment newFragment = new TimePickerFragment();
		newFragment.show(getFragmentManager(), "timePicker");
	}
	
	public void showDatePickerDialog(View v) {
	    DialogFragment newFragment = new DatePickerFragment();
	    newFragment.show(getFragmentManager(), "datePicker");
	}
	
}
